﻿<template class="app-dependencies-check-dialog">
    <h4 class="d-flex justify-content-between">
        <div>
            App Dependency Check
            <span class="spinner-border float-end" if.bind="loading"></span>
        </div>
        <i class="app-deps-check-icon"></i>
    </h4>

    <div if.bind="!loading">
        <div class="section">
            <h5>
                <i class="check-circle-icon text-green"></i>
                .NET Runtime
            </h5>

            <div class="section-details">
                NetPad is running on .NET runtime <code>v${input.dotNetRuntimeVersion}</code>
            </div>
        </div>

        <div class="section">
            <h5>
                <i class="${dotnetSdkMissing ? 'error-icon text-red' : 'check-circle-icon text-green'}"></i>
                .NET SDK
            </h5>

            <div class="section-details">
                <div if.bind="!report.resolvedPath">
                    Could not find a .NET SDK installation. Searched paths:

                    <ul class="sdk-versions-list">
                        <li repeat.for="step of report.searchSteps">
                            <div class="d-flex align-items-center justify-content-between" style="max-width: 400px">
                                <code>${step.location.path}</code>
                            </div>
                        </li>
                    </ul>
                </div>
                <div else>
                    <div class="mb-3">
                        Found .NET SDK installation:
                        <code>${report.resolvedPath.path}</code>
                    </div>

                    <div if.bind="dotnetSdkMissing">
                        <span class="text-red">No supported .NET SDK could be found.</span>
                        <br/>
                        Make sure the .NET SDK version 6 or greater is installed and the <code>dotnet</code>
                        executable is in your <code>PATH</code>.

                        <span if.bind="input.dotNetSdkVersions?.length">All installed SDKs:</span>
                    </div>
                    <div else>
                        <b>${input.supportedDotNetSdkVersionsInstalled.length}</b> supported .NET SDKs are
                        installed. All installed SDKs:
                    </div>

                    <div if.bind="input.dotNetSdkVersions?.length">
                        <ul class="sdk-versions-list">
                            <li repeat.for="version of input.dotNetSdkVersions">
                                <code>${version.string}</code>
                                <span class="badge text-green ms-3"
                                      if.bind="input.supportedDotNetSdkVersionsInstalled.map(x => x.string).indexOf(version.string) >= 0">
                                Supported
                            </span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>

        <div class="section">
            <h5>
                <i class="${dotnetEfCoreToolMissing ? 'warning-icon text-yellow' : 'check-circle-icon text-green'}"></i>
                Entity Framework Core .NET Tool
                <small if.bind="!dotnetEfCoreToolMissing">
                    (installed: <code>v${input.dotNetEfToolVersion.string}</code>)
                </small>
            </h5>

            <div class="section-details">
                <div if.bind="dotnetEfCoreToolMissing">
                    <span>Entity Framework Core .NET tool is not installed.</span>
                    <br/>
                    <b>This is optional</b>, but you will need to install version 5 (or higher) of the
                    <code>dotnet-ef</code> tool and ensure it is in your <code>PATH</code> if you want to be
                    able to add and use database connections.
                </div>
                <div else>
                    Entity Framework Core .NET tool is installed.
                </div>
            </div>
        </div>

        <div class="section"
             if.bind="dotnetSdkMissing || dotnetEfCoreToolMissing">
            <i class="info-icon text-blue"></i>
            Please restart NetPad after installing any of the dependencies above.
        </div>
    </div>

    <hr/>

    <div class="bottom-bar" if.bind="loading">
        <span>Gathering requirements...</span>
        <div class="buttons">
            <button class="btn btn-primary" click.trigger="cancel()">Cancel</button>
        </div>
    </div>
    <div class="bottom-bar" else>
        <div></div>
        <div class="buttons">
            <a class="btn btn-primary"
               external-link
               href="https://dotnet.microsoft.com/en-us/download/dotnet">Download .NET SDK</a>
            <a class="btn btn-secondary"
               external-link
               href="https://learn.microsoft.com/en-us/ef/core/cli/dotnet#installing-the-tools">Download EF Core
                Tool</a>
            <button class="btn-cancel btn btn-secondary" click.trigger="cancel()">Close</button>
        </div>
    </div>
</template>
